package Day07;
import java.util.Scanner;
public class CalAirPrice {
    public static void main(String[] args) {
        Scanner input1 = new Scanner(System.in);
        while (true) {
            System.out.println("请分别输入：机票原价，月份，和舱位（头等舱输入1，商务舱输入2，经济舱输入3):");
            double price = input1.nextInt();
            int month = input1.nextInt();
            int zoom = input1.nextInt();
            //判断输入对错
            int rightAndWrong = rightAndWrong(month,zoom);
            if (rightAndWrong == -1) {
                System.out.println("输入错误，重新计算：");
                continue;
            }
            //判断舱位
            String zoom1 = zoomChoice(zoom);
            //计算价格
            double finalPrice = calAirPrice(price,month,zoom);
            System.out.print(zoom1+"机票的最终价格为："+finalPrice+"！按1继续计算，按其他任意键退出计算：");
            int number2 = input1.nextInt();
            if(number2 == 1) {

            } else {
                break;
            }
        }




    }

    public static double calAirPrice (double price,int month,int zoom) {
        if (month >= 5 && month <= 10) {
            switch (zoom) {
                case 1:
                    price *= 0.8;
                    break;
                case 2:
                    price *= 0.7;
                    break;
                case 3:
                    price *= 0.65;
                    break;
            }
        } else  {
            switch (zoom) {
                case 1:
                    price *= 0.8;
                    break;
                case 2:
                    price *= 0.7;
                    break;
                case 3:
                    price *= 0.65;
            }
        }
        System.out.println();

        return price;

    }
    public static String zoomChoice (int zoom) {
        String zoom1 = "舱位";
        switch (zoom) {
            case 1:
                zoom1 = "头等舱";
                break;
            case 2:
                zoom1 = "商务舱";
                break;
            case 3:
                zoom1 = "经济舱";
        }
        return zoom1;
    }
    public static int rightAndWrong (int month,int zoom) {
        if (month<1 || month>12) {
            return -1;
        }
        if (zoom<1 || zoom>3) {
            return -1;
        }
        return 0;
    }
}
